#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QDebug>
#include "helper.h"
#include <QMenuBar>
#include <writer.h>
#include <qfont.h>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar * bar = menuBar();
    setMenuBar(bar);
    QFont Menu_font("Microsoft YaHei",12, 75);
    QMenu * startMenu = bar->addMenu("· · ·");
    bar->setFont(Menu_font);
    QAction * start = startMenu->addAction("开始游戏");
    QAction * help = startMenu->addAction("帮助");
    QAction * quit = startMenu->addAction("退出");
    startMenu -> addSeparator();
    QAction * shiki = startMenu->addAction("猜猜这是啥");
    this->setWindowTitle("扫雷");
    this->setFixedSize(800,600);
    QPushButton * startbtn = new QPushButton("开      始",this);
    startbtn->resize(300,100);
    startbtn->move(this->width()*0.5-startbtn->width()*0.5,this->height()*0.35);
    QPushButton * helpbtn = new QPushButton("帮      助",this);
    helpbtn->resize(300,100);
    helpbtn->move(this->width()*0.5-startbtn->width()*0.5,this->height()*0.55);
    QPushButton * quitbtn = new QPushButton("退      出",this);
    quitbtn->resize(300,100);
    quitbtn->move(this->width()*0.5-startbtn->width()*0.5,this->height()*0.75);
    chooselevel = new levelchoose;
    connect(startbtn,&QPushButton::clicked,[=](){
        this->hide();
        chooselevel->show();
    });
    connect(helpbtn,&QPushButton::clicked,[=](){
        helper * helplist = new helper;
        helplist -> show();
    });
    connect(quitbtn,&QPushButton::clicked,[=](){
        this->close();
    });
    connect(start,&QAction::triggered,[=](){
        emit startbtn->clicked();
    });
    connect(quit,&QAction::triggered,[=](){
        emit quitbtn->clicked();
    });
    connect(help,&QAction::triggered,[=](){
        emit helpbtn->clicked();
    });
    connect(shiki,&QAction::triggered,[=](){
        writer * W = new writer;
        W->show();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
